package com.github.prontera.util.converter.jackson;

import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

/**
 * @author Alex
 */
public class LocalDateToIso8601Serializer extends JsonSerializer<LocalDate> {

	public static final LocalDateToIso8601Serializer INSTANCE = new LocalDateToIso8601Serializer();

	@Override
	public void serialize(LocalDate dateTime, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
		 jsonGenerator.writeString(dateTime.format(DateTimeFormatter.ISO_DATE));
	}

}
